package com.jboltai.event.signal;

import com.jboltai.event.Event;
import com.jboltai.event.EventError;
import com.jboltai.event.EventErrorType;
import com.jboltai.event.EventType;
import com.jboltai.event.handler.FailEventHandler;

import static com.jboltai.event.EventType.SIGNAL_FAIL;

/**
 * 特殊事件。不会执行onsuccess回调
 */
public class FailEvent extends Event<FailEvent, EventError, FailEventHandler> {


    public FailEvent(String errorMsg) {
        super(SIGNAL_FAIL);
        this.error = new EventError(EventErrorType.CHAIN_NODE_FAIL, errorMsg, null );
    }

    public FailEvent(EventError error) {
        super(SIGNAL_FAIL);
        this.error = error;
    }

    protected FailEvent(EventType type) {
        super(SIGNAL_FAIL);
    }

    @Override
    public String preCheck() {
        return null;
    }

    @Override
    public EventError getError() {
        return error;
    }

    @Override
    public void setError(EventError error) {
        this.error = error;
    }
}
